<?php

/**
 * 后台首页
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zwt007 $  <zwttmac@qq.com>
 * $Id: index.php 45 2011-07-16 10:50:25Z zwt007 $
 * http://www.t-mac.org；
 */
class indexAction extends Action
{

    //定义初始化变量
    private $menu;

    public function _init()
    {
        //加载并返回Model文件夹下的Model对象。
        $this->menu = Tmac::model('Menu');
        $check_model = $this->M('check');
        $check_model->checkLogin();
        $check_model->CheckPurview('tb_admin,tb_editer');
    }

    public function index()
    {
        $menusMain = "        
        <m:top mapitem='0' name='分类' rank='tb_admin'>
          <m:item name='分类管理' link='" . PHP_SELF . "?m=category' rank='tb_admin' target='main' />
          <m:item name='添加分类' link='" . PHP_SELF . "?m=category.add' rank='tb_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='文章' rank='tb_admin'>
          <m:item name='文章管理' link='" . PHP_SELF . "?m=archives.arclist' rank='tb_admin' target='main' />
          <m:item name='添加新文章' link='" . PHP_SELF . "?m=archives.add' rank='tb_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='链接' rank='tb_admin'>
          <m:item name='链接管理' link='" . PHP_SELF . "?m=link' rank='tb_admin' target='main' />
          <m:item name='添加新链接' link='" . PHP_SELF . "?m=link.add' rank='tb_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='招聘' rank='tb_admin'>
          <m:item name='招聘信息管理' link='" . PHP_SELF . "?m=comment' rank='tb_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='用户' rank='tb_admin'>
          <m:item name='用户管理' link='" . PHP_SELF . "?m=user' rank='tb_admin' target='main' />
          <m:item name='添加新用户' link='" . PHP_SELF . "?m=user.add' rank='tb_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='工具' rank='tb_admin'>
          <m:item name='数据库备份' link='" . PHP_SELF . "?m=data.back' rank='tb_admin' target='main' />
          <m:item name='数据库还原' link='" . PHP_SELF . "?m=data.revert' rank='tb_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='设置' rank='tb_admin'>
          <m:item name='网站设置' link='" . PHP_SELF . "?m=config' rank='tb_admin' target='main' />
          <m:item name='退出系统' link='" . PHP_SELF . "?m=login.out' rank='tb_admin' target='main' />
        </m:top>
        ";
        //取config配置文件
        $configcache = Tmac::config('configcache.config.cfg_indexurl', APP_NAME, '.inc.php');
        $this->assign('admin_title', $GLOBALS['TmacConfig']['config']['admin_title']);
        $this->assign('indexurl', $configcache);
        $this->assign('menua', $this->menu->getMenua($menusMain));
        $this->V();
    }

    public function body()
    {
        $verLockFile = VAR_ROOT . 'Data/ver.txt';
        $fp = fopen($verLockFile, 'r');
        $upTime = trim(fread($fp, 64));
        fclose($fp);
        $this->assign('gdversion', $this->menu->gdversion());
        $this->assign('upTime', $upTime);
        $this->V('index_body');
    }

}